from django.shortcuts import render
from django.http import HttpResponse
from booktest.models import *

# Create your views here.

def index(request):
    return HttpResponse("hello world")

def index1(request):
    context={"name":"xcc",'title':"测试一下","list":range(10)}
    return render(request,'booktest/index.html',context)

def index2(request):
    booklist=BookInfo.objects.all()
    context={"booklist":booklist}
    return render(request,'booktest/index2.html',context)

def detail(request,id):
    book=BookInfo.objects.get(id=id)
    context={"book":book}
    return HttpResponse(str(book))
    # return render(request,'booktest/index2.html',context)
